<template>
  <div class="child">
    <h3>我是Child组件</h3>
    <h3>当前求和：{{sum}}</h3>
  </div>
</template>
  
<script>
import { ref } from 'vue';
  export default {
    name: 'Child',
    setup() {
      let sum = ref(0)
      //用于测试：如果setup返回promise，则vue会自动调用promise.then等待执行完成后再加载组件
      return new Promise((resolve, reject)=>{
        setTimeout(()=>{
          resolve({sum})
        }, 2000)
      })
    }
  }
</script>
  
<style>
  .child{
    background-color: skyblue;
    padding: 10px;
  }
</style>
  